
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Trans extends CI_Controller {

  public function __construct()
  {
    parent::__construct();
    $this->load->model('mmaster');
    $this->load->model('mglobal');
    $this->load->model('mtrans');
    $this->index();
  }

  public function index()
  {
    $is_logged_in = $this->session->userdata('is_logged_in');
    if(!isset($is_logged_in) || $is_logged_in != true)
      { redirect(base_url() .'index.php/login'); } 
  }

  ## main function on sell in
  public function sell()
  {
    $template = "shell/smooth";
    $data["main_view"] = "trans/create_sell";

    $cluster_id = $this->mglobal->user_cluster( $this->session->userdata('username') );

    $data["territory"] = $this->mglobal->get_territory( $cluster_id );
    $data["sales"] = $this->mtrans->sell_in_sales_team( $cluster_id, array(8, 9, 54) ); // array(SFA, DS, SMI)
    $this->load->view($template, $data);
  }


  ## YADDIS ONLY =========================================================================

  ## AJAX ONLY (XHR) =====================================================================
  public function get_partners( $user_group_id, $sales_id )
  {
    $data = $this->mtrans->get_partners( $user_group_id, $sales_id );
    echo json_encode($data);
  }

  public function get_program( $user_group_id, $channel_id )
  {
    $data = $this->mtrans->get_program( $user_group_id, $channel_id );
    echo json_encode($data);
  }
}

/* End of file trans.php */
/* Location: ./application/controllers/trans.php */